home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-03-02 | 2.5 KB | 88 lines | [TEXT/MPS ] |
- Title 'Force RAM Disk on and to a specific size' ;
- *
- * Module for "Force" shell.
- * Ben Cranston March 1, 1994
- *
- Print Off ; Here be includes
- Include 'GestaltEqu.a' ;
- Include 'Traps.a' ;
- Print On,NoGen ; Here be includes
- Main ; Begin module
- *
- S Record {A6Link},Decr ; Stack frame
- A6Link DS.L 1 ; Caller's A6
- Curr DS.B 1 ; Current PRAM value
- Want DS.B 1 ; Desired PRAM value
- Prog DS.L 1 ; Pointer to setup resource
- SS Equ * ; Stack size
- EndR ; Stack frame
- *
- Link A6,#S.SS ; Make local frame
- Tst.L D1 ; Did we get a data resource?
- BEq.S @999 ; If error then get out
- Move.L D1,S.Prog(A6) ; Save handle
- *
- * If not 68040 hardware then just get out
- *
- Move.L #gestaltProcessorType,D0 ; Ask about processor type
- _Gestalt ; Get processor type
- BNE.S @900 ; If error then get out
- Cmp.W #gestalt68040,A0 ; Is this a quadra?
- BNE.S @900 ; If not then just get out
- *
- Eject ;
- *
- * Get physical memory size and compute desired RAM disk size.
- *
- Move.L #gestaltPhysicalRAMSize,D0 ; Ask about memory size
- _Gestalt ; Get memory size
- BNE.S @900 ; If error then get out
- Move.L A0,D2 ; Get size in bytes
- Move.W #20,D0 ; Get shift count
- LSR.L D0,D2 ; Get size in megabytes
- Clr.B S.Want(A6) ; Initially set no RAM disk
- Move.L S.Prog(A6),A0 ; Get handle to program
- _GetHandleSize ; Get size of program
- Move.L (A0),A0 ; Get pointer to program
- @010 ;
- Sub.L #2,D0 ; Count program bytes
- BLT.S @030 ; If out of program, no disk
- Move.B (A0)+,D1 ; Get next size to test
- Cmp.B D2,D1 ; Is this enough memory?
- BLE.S @020 ; Yes, go set disk size
- Add.L #1,A0 ; Else skip byte
- Bra.S @010 ; Go do next cycle
- @020 ;
- Move.B (A0)+,D0 ; Get desired size in MB
- MulU.W #250,D0 ; Compute size key
- DivU.W D2,D0 ; Compute size key
- Move.B D0,S.Want(A6) ; Set size of RAM disk
- *
- * Get current PRAM contents, decide if we have to reset and reboot.
- *
- @030 ;
- Move.L #$000100AF,D0 ; Byte AF
- LEA S.Curr(A6),A0 ; Point to stack space
- _ReadXPram ; Read current from parameter RAM
- BNE.S @999 ; If error then get out
- Move.B S.Curr(A6),D1 ; Get current alt level
- Cmp.B S.Want(A6),D1 ; Same as desired?
- BEq.S @999 ; If so then skip
- *
- * Write desired contents to PRAM and force reboot.
- *
- LEA S.Want(A6),A0 ; Get address of desired
- Move.L #$000100AF,D0 ; Byte AF
- _WriteXPram ; Write back to parameter RAM
- Move.L #1,D0 ; Set flat to force reboot
- Bra.S @999 ; Return to driver
- *
- @900 ;
- Clr.L D0 ; Set no reboot
- @999 ;
- UnLk A6 ; Drop local frame
- RTS ; Return to INIT31
- *
- EndMain ; Keep MPW happy
- End ; ForceRAMDisk.a
-